﻿//----------------------------------------------------
//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Data;
using System.Text;

using System.Linq;
using WinnerCMS.Common;
using WinnerCMS.Model;
using System.Data.Entity;
namespace WinnerCMS.Data
{
    /// <summary>
    /// 数据访问层CMS_CounterContent。
    /// </summary>
    public class CounterContentDal
    {
     
        #region  取得数据
        /// <summary>
        /// 取得数据
        /// </summary>
        public CounterContent GetInfo()
        {
            using (Entities db = new Entities())
            {
                return db.CounterContents.FirstOrDefault();
            }
        }
        #endregion

        #region  添加数据
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        public void Add(CounterContent model)
        {
            using (Entities db = new Entities())
            {
                db.CounterContents.Add(model);
                db.SaveChangesAsync().Wait();
            }
        }
        #endregion

        #region  修改数据
        /// <summary>
        /// 修改
        /// </summary>
        public void Edit(CounterContent model)
        {
            using (Entities db = new Entities())
            {
                db.CounterContents.Attach(model);
                db.Entry(model).State = EntityState.Modified;
                db.SaveChangesAsync().Wait();
            }
        }
        #endregion
    }
}